import os
import sys
import struct

# 时间转为分钟数
def time_to_minute(path):
    size = os.stat(path).st_size
    count = int(size/34)
    print(count)
    with open(path,'rb+') as file:
        for i in range(count):
            file.seek(i*34 + 4)
            byte = file.read(2)
            time = struct.unpack('h', byte)[0]
            minute = int(time/100)*60 + time % 100
            new_bype = struct.pack('<h', minute)
            file.seek(i*34 + 4)
            file.write(new_bype)
            # print(time,minute)

        
if __name__=="__main__":
    path = sys.argv[1]
    for root,dirs,files in os.walk(path):
        # for dir in dirs:
            # print(os.path.join(root,dir))
        for file in files:
            old_path = os.path.join(root,file)
            print('开始转换'+old_path)
            time_to_minute(old_path)
